import RenderAuthorized from 'components/authorized';
import auth from 'components/common/auth';

function loginValidate() {
  if (auth.loggedIn()) {
    return 'admin';
  } else {
    if (auth.getAccessToken()) {
      auth.refreshToken();
    }
    return 'guest';
  }
}

function getAuthority() {
  return loginValidate();
}

let Authorized = RenderAuthorized(getAuthority());

const reloadAuthorized = () => {
  Authorized = RenderAuthorized(getAuthority());
};

export { reloadAuthorized };
export default Authorized;
